import 'package:flutter/material.dart';
import 'package:flutter_todo_ohos/routes/index.dart';
import 'package:get/get.dart';
import 'package:getx_scaffold_ohos/getx_scaffold_ohos.dart';

import '../../gen_a/A.dart';
import 'home_controller.dart';

class HomePage extends StatelessWidget {
  HomePage({super.key});

  final HomeController controller = Get.put(HomeController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: GetBuilder<HomeController>(
          id: "home",
          init: controller,
          builder: (controller) {
            return Column(
              children: [
                Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.only(
                        bottomLeft: Radius.circular(16.r),
                        bottomRight: Radius.circular(16.r),
                      ),
                      border: const Border(
                          bottom: BorderSide(
                              color: Color(0xFF979797), width: 0.2))),
                  width: double.infinity,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      SizedBox(height: 8.h),
                      Text(
                        '今天',
                        style: TextStyle(
                            color: Colors.black,
                            fontSize: 24.sp,
                            fontWeight: FontWeight.w500),
                      ),
                      SizedBox(height: 16.h),
                      Text(
                        '4月18日 周六',
                        style: TextStyle(
                          color: Colors.black,
                          fontSize: 14.sp,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                      SizedBox(height: 16.h),
                      Container(
                        decoration: BoxDecoration(
                          color: const Color(0xFFF6F6F6),
                          borderRadius: BorderRadius.circular(20.r),
                        ),
                        margin: EdgeInsets.symmetric(horizontal: 16.w),
                        padding: EdgeInsets.symmetric(horizontal: 14.w),
                        height: 40.h,
                        child: Row(
                          children: [
                            Text(
                              '快速搜索',
                              style: TextStyle(
                                  color: Colors.black.withOpacity(0.5),
                                  fontSize: 15.sp),
                            ),
                            const Spacer(),
                            Image.asset(
                              A.assets_images_search,
                              width: 18.w,
                              height: 18.w,
                            )
                          ],
                        ),
                      ).onTap(() {
                        print("搜索");
                      }),
                      SizedBox(height: 28.h),
                    ],
                  ),
                ),
                const Spacer(),
                Container(
                  width: double.infinity,
                  height: 60.h,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(16.r),
                        topRight: Radius.circular(16.r),
                      ),
                      border: const Border(
                          top: BorderSide(
                              color: Color(0xFF979797), width: 0.2))),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      IconButton(
                        onPressed: () {},
                        highlightColor: Colors.transparent,
                        splashColor: Colors.transparent,
                        iconSize: 30.w,
                        icon: Image.asset(A.assets_images_menu),
                      ),
                      IconButton(
                        onPressed: () {},
                        highlightColor: Colors.transparent,
                        splashColor: Colors.transparent,
                        iconSize: 50.w,
                        icon: Image.asset(A.assets_images_add_event),
                      ),
                      IconButton(
                        onPressed: () {
                          Get.toNamed(RouteKey.login);
                        },
                        highlightColor: Colors.transparent,
                        splashColor: Colors.transparent,
                        iconSize: 30.w,
                        icon: Image.asset(A.assets_images_user_icon,),
                      ),
                    ],
                  ),
                ),
              ],
            );
          },
        ),
      ),
    );
  }
}
